/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sqlconnect;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author salm
 */
class SQLBaseConnection implements SQLConnection
{
    private static final String driverURL = "sun.jdbc.odbc.JdbcOdbcDriver";
    private static final String JDBCHeader = "jdbc:odbc";
    private static final String SQLDriver = "{SQL Server}";
    
    public SQLBaseConnection(String serverName, String databaseName, String account, String password) throws SQLException
    {
        try
        {
            Class.forName(driverURL);

            String dbConnectURL = String.format("%s:Driver=%s;Server=%s;Database=%s", JDBCHeader, SQLDriver, serverName, databaseName);
            sqlConnection = DriverManager.getConnection(dbConnectURL, account, password);
        }
        catch (ClassNotFoundException ex)
        {
            Logger.getLogger(SQLBaseConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private Connection sqlConnection;

    /**
     * @return the sqlConnection
     */
    @Override
    public Connection getSqlConnection()
    {
        return sqlConnection;
    }
}
